class code4_2 {
    public int[] shortestToChar(String s, char c) {
        int n = s.length();
        int[] ret = new int[n];
        Arrays.fill(ret,n+1)
        //i前面找c
        char[] ss = s.toCharArray();
        for(int i=0,j=-1;i<n;i++) {
            if(ss[i] == c) j = i;
            if(j != -1) ret[i] = i-j;
        }
        //i后面找c
        for(int i=n-1,j=-1;i>0;i--) {
            if(ss[i] == c) j = i;
            if(j != -1) ret[i] = Math.min(ret[i],j-i);
        }
        return ret;
    }
}